-- An arbitrary function can be approximated by a weighted sum of Chebyshev polynomials.
-- A Chebyshev polynomial of degree n is defined as:
-- T(x)[n] = 1 when n=0,
-- x when n=1,
-- 2*x*T(x)[n-1] - T(x)[n-2]
-- or the explicit formula:
T(x)[n] = cos(n*acos(x))
Xmin=-1; Xmax=1; Title="Chebyshev polynomials"
plot T(X)[0:6] -- show the first few polynomials
-- The weighting coefficients can be calculated using the values of the arbitrary function at the zeros of T(x). T(x)[N] has N zeros between -1 and +1 located at: